package me.qingy.core.service.impl;

import me.qingy.core.entity.Menu;
import me.qingy.core.service.MenuService;
import me.qingy.core.mapper.MenuMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * <p>
 * 菜单权限表 服务实现类
 * </p>
 *
 * @author qingy
 * @since 2021-04-21
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {

    @Override
    public Set<String> selectMenuPermsByUserId(Long userId) {
        List<String> perms = this.baseMapper.selectPermsByUserId(userId);
        return perms.stream().filter(StringUtils::isNotEmpty).collect(Collectors.toSet());
    }

}
